﻿using System;
using RootMotion.FinalIK;
using UnityEngine;

namespace RootMotion.Demos
{
	// Token: 0x0200009D RID: 157
	public class ExplosionDemo : MonoBehaviour
	{
		// Token: 0x06000554 RID: 1364 RVA: 0x000055C7 File Offset: 0x000037C7
		public void Start()
		{
			this.defaultScale = base.transform.localScale;
			this.r = this.character.GetComponent<Rigidbody>();
			this.ik = this.character.GetComponent<FullBodyBipedIK>();
		}

		// Token: 0x06000555 RID: 1365 RVA: 0x000348AC File Offset: 0x00032AAC
		public void Update()
		{
			this.weight = Mathf.Clamp(this.weight - Time.deltaTime * this.weightFalloffSpeed, 0f, 1f);
			if (Input.GetKeyDown(KeyCode.E) && this.character.isGrounded)
			{
				this.ik.solver.IKPositionWeight = 1f;
				this.ik.solver.leftHandEffector.position = this.ik.solver.leftHandEffector.bone.position;
				this.ik.solver.rightHandEffector.position = this.ik.solver.rightHandEffector.bone.position;
				this.ik.solver.leftFootEffector.position = this.ik.solver.leftFootEffector.bone.position;
				this.ik.solver.rightFootEffector.position = this.ik.solver.rightFootEffector.bone.position;
				this.weight = 1f;
				Vector3 vector = this.r.position - base.transform.position;
				vector.y = 0f;
				float d = this.explosionForceByDistance.Evaluate(vector.magnitude);
				this.r.velocity = (vector.normalized + Vector3.up * this.upForce) * d * this.forceMlp;
			}
			if (this.weight < 0.5f && this.character.isGrounded)
			{
				this.weight = Mathf.Clamp(this.weight - Time.deltaTime * 3f, 0f, 1f);
			}
			this.SetEffectorWeights(this.weightFalloff.Evaluate(this.weight));
			base.transform.localScale = this.scale.Evaluate(this.weight) * this.defaultScale;
		}

		// Token: 0x06000556 RID: 1366 RVA: 0x00034AD4 File Offset: 0x00032CD4
		public void SetEffectorWeights(float w)
		{
			this.ik.solver.leftHandEffector.positionWeight = w;
			this.ik.solver.rightHandEffector.positionWeight = w;
			this.ik.solver.leftFootEffector.positionWeight = w;
			this.ik.solver.rightFootEffector.positionWeight = w;
		}

		// Token: 0x0400042A RID: 1066
		public SimpleLocomotion character;

		// Token: 0x0400042B RID: 1067
		public float forceMlp = 1f;

		// Token: 0x0400042C RID: 1068
		public float upForce = 1f;

		// Token: 0x0400042D RID: 1069
		public float weightFalloffSpeed = 1f;

		// Token: 0x0400042E RID: 1070
		public AnimationCurve weightFalloff;

		// Token: 0x0400042F RID: 1071
		public AnimationCurve explosionForceByDistance;

		// Token: 0x04000430 RID: 1072
		public AnimationCurve scale;

		// Token: 0x04000431 RID: 1073
		public float weight;

		// Token: 0x04000432 RID: 1074
		public Vector3 defaultScale = Vector3.one;

		// Token: 0x04000433 RID: 1075
		public Rigidbody r;

		// Token: 0x04000434 RID: 1076
		public FullBodyBipedIK ik;
	}
}
